/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.boxin.ims.modules.travel.web.front;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.boxin.ims.modules.travel.entity.Bus;
import com.boxin.ims.modules.travel.service.BusService;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.web.BaseController;

/**
 * 车辆Controller
 * @author Jakemanse
 * @version 2013-07-31
 */
@Controller
@RequestMapping(value = Global.FRONT_PATH+"/travel/bus")
public class BusFrontController extends BaseController {

	@Autowired
	private BusService busService;
	
	@RequestMapping(value = {"view" + "/{id}" +Global.URL_SUFFIX, ""})
	public String view( @PathVariable  Long id ,HttpServletRequest request , HttpServletResponse response) {
		
		Bus bus  = busService.get(id);
		String type = request.getParameter("type");
		if("toString".equals(type) &&bus!=null){
			try {
				response.setCharacterEncoding("UTF-8");
				PrintWriter out = response.getWriter();
				
				out.print(bus.toString());
				out.flush();
				out.close();
				return null;
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		request.setAttribute("bus", bus);
		
		return "modules/travel/front/busView";
	}
	
	


}
